﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using Zocono.Infrastructure.Common;
using Zocono.WCS.Application.AppConfigureManage;
using Zocono.WCS.Domain.EntityInfo;
using Zocono.WCS.Infrastructure.ApllicationDto.DtoWcsManage;

namespace Zocono.WCS.WebApi.Controllers
{
    [Route("api/[controller]/[Action]")]
    [ApiController]
    public class PlcPointInfoController : ControllerBase
    {
        private readonly ILogUtil _ILogUtil;
        private readonly PlcPointInfoApp _PlcPoinInfoApp;
        public PlcPointInfoController(ILogUtil iLogUtil, PlcPointInfoApp plcPoinInfoApp)
        {
            _ILogUtil = iLogUtil;
            _PlcPoinInfoApp = plcPoinInfoApp;
        }

        [HttpPost]
        public async Task<HeaderResult<bool>> InsertPlcPointInfoAsync(PlcPointInfoDto plcPointInfo)
        {
            HeaderResult<bool> headerResult=new HeaderResult<bool>();
            try
            {
                var res = await _PlcPoinInfoApp.InsertPlcPointInfoAsync(plcPointInfo);
                if (res)
                {
                    headerResult.Message = "插入成功";
                    headerResult.IsSucceed = true;
                }
                else
                {
                    headerResult.Message = "插入失败";
                    headerResult.IsSucceed = false;
                }
                headerResult.IsSucceed = res;
            }
            catch (System.Exception ex)
            {
                headerResult.Message = "插入失败"+ex.Message;
                headerResult.IsSucceed = false;
            }

            return headerResult;
        }

        //[HttpPost]
        //public async Task<HeaderResult<List<PlcPointInfoDto>>> GetPlcPointInfoAsync(PlcPointInfoDto plcPointInfo)
        //{
        //    HeaderResult<List<PlcPointInfoDto>> headerResult=new HeaderResult<List<PlcPointInfoDto>>();
        //    try
        //    {
        //        var res= await _PlcPoinInfoApp.GetPlcPointInfoAsync(plcPointInfo);
        //        if (res != null)
        //        {
        //            headerResult.Result = res;
        //            headerResult.Message = "查询成功";
        //            headerResult.IsSucceed = true;
        //        }
        //        else
        //        {
        //            headerResult.Message = "查询失败";
        //            headerResult.IsSucceed = false;

        //        }

        //    }
        //    catch (System.Exception ex)
        //    {

        //        headerResult.Message = "查询失败" + ex.Message;
        //        headerResult.IsSucceed = false;
        //    }
        //    return headerResult;
        //}


    }
}
